package com.zut.hospital.controller.staff;

import com.alibaba.fastjson.JSONObject;
import com.zut.hospital.entity.staff.Office;
import com.zut.hospital.service.staff.OfcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author hyx
 * @date 2019/6/4 16:16
 * @description TODO
 * @Version
 */
@Controller
@RequestMapping("/hospital")
public class OfcController {
    @Autowired
    OfcService ofcService;

    @ResponseBody
    @RequestMapping("/getOfc")
    List<Office> getAllOfc(){
        return ofcService.getAllOfc();
    }

    public Office setOffice(String message){
        Office office=JSONObject.parseObject(message,Office.class);
        return office;
    }

    @ResponseBody
    @RequestMapping(value = "/addOfc",method = RequestMethod.POST)
    public int insertOfc(@RequestBody String message){
        return ofcService.insertOfc(setOffice(message));
    }



}
